]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
breakManager: Rework notification urgency setting and presentation
authorPhilip Withnall <pwithnall@gnome.org>
Tue, 8 Apr 2025 14:32:36 +0000 (15:32 +0100)
committerMarge Bot <marge-bot@gnome.org>
Fri, 11 Apr 2025 13:18:48 +0000 (13:18 +0000)
Move the setting of the notification’s urgency, and adding the
notification to the queue, to beside where the notification is created.

This avoids the potential for changing the urgency of an existing
notification if none of the branches above are taken, and
`this._notification` is non-empty.

Spotted by Florian Müllner in
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3687#note_2405781.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3687>

js/misc/breakManager.js

index d9b1cb3d6d70852bcc2d2ab77635592d2764d5ee..65b74093031ac9ace7e9527bcf5dc6480135c2ca 100644 (file)
@@ -1100,6 +1100,7 @@ class BreakNotificationSource extends GObject.Object {
                                 title: titleText,
                                 body: bodyText,
                                 sound: null,
+                                urgency: this._urgencyForBreakType(nextBreakType),
                                 allowDelay: true,
                                 allowSkip: true,
                                 allowTake: false,
@@ -1228,10 +1229,12 @@ class BreakNotificationSource extends GObject.Object {
                     title: titleText,
                     body: bodyText,
                     sound: null,
+                    urgency: this._urgencyForBreakType(nextBreakType),
                     allowDelay: true,
                     allowSkip: false,
                     allowTake: true,
                 });
+                this._source.addNotification(this._notification);
 
                 this._scheduleUpdateState(BREAK_OVERDUE_TIME_SECONDS);
             } else if (breakDueAgo >= BREAK_OVERDUE_TIME_SECONDS &&
@@ -1248,10 +1251,12 @@ class BreakNotificationSource extends GObject.Object {
                     title: _('Break Overdue'),
                     body: bodyText,
                     sound: null,
+                    urgency: this._urgencyForBreakType(nextBreakType),
                     allowDelay: true,
                     allowSkip: false,
                     allowTake: true,
                 });
+                this._source.addNotification(this._notification);
 
                 this._scheduleUpdateState(updateTimeoutSeconds);
             } else if (this._previousState === BreakState.IN_BREAK) {
@@ -1268,19 +1273,16 @@ class BreakNotificationSource extends GObject.Object {
                     title: _('Break Interrupted'),
                     body: bodyText,
                     sound: null,
+                    urgency: this._urgencyForBreakType(nextBreakType),
                     allowDelay: false,
                     allowSkip: false,
                     allowTake: false,
                 });
+                this._source.addNotification(this._notification);
 
                 this._scheduleUpdateState(updateTimeoutSeconds);
             }
 
-            if (this._notification) {
-                this._notification.urgency = this._urgencyForBreakType(this._manager.currentBreakType);
-                this._source.addNotification(this._notification);
-            }
-
             break;
         }